package com.star.warmwinter.module.user.viewCtrl;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import com.star.warmwinter.R;
import com.star.warmwinter.module.user.ui.CommonLoginTelActivity;
import com.star.warmwinter.module.user.ui.LoginIndexActivity;
import com.star.warmwinter.module.user.viewModel.CommonLoginVM;
import com.star.warmwinter.widget.ThemeToast;

import static com.star.warmwinter.module.user.ui.CommonLoginTelActivity.LOGIN_TYPE_KEY;

/**
 * Author: blackbai11
 * Date: 2018/5/31
 * Description: 通用登录页面控制器({@link LoginIndexActivity,CommonLoginTelActivity})
 */
public class CommonLoginCtrl implements View.OnClickListener {
    protected Context mContext;
    protected CommonLoginVM commonLoginVM;

    public CommonLoginCtrl(Context context) {
        mContext = context;
        commonLoginVM = new CommonLoginVM();
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            case R.id.img_close:
                ThemeToast.showShort("返回-main");
                break;

            case R.id.img_register:
                intent = new Intent(mContext, CommonLoginTelActivity.class);
                intent.putExtra(LOGIN_TYPE_KEY, CommonLoginTelActivity.LOGIN_TYPE_REGISTER);
                mContext.startActivity(intent);
                break;

            case R.id.img_login:
                intent = new Intent(mContext, CommonLoginTelActivity.class);
                intent.putExtra(LOGIN_TYPE_KEY, CommonLoginTelActivity.LOGIN_TYPE_LOGIN);
                mContext.startActivity(intent);
                break;
        }
    }

    public CommonLoginVM getCommonLoginVM() {
        return commonLoginVM;
    }
}
